demo0 = function () {
    $.sleep(100).then(() => {
        str = {
            "key": "hello",
            "value": ""
        };
        str = JSON.stringify(str);
        ws.send(str);
        setInterval("demo()",  600);
        setInterval("demoNet()", 1000);
    });
}

countR = 1;

demo = function () {
    if(ws.readyState === 1) {
        $.sleep(Math.random() * 100 + 800).then(() => {
            str = {
                "key": "statistics/task",
                "value": {
                    "task": {
                        "arriveAt": 2,
                        "deadline": 1000,
                        "delay": 42,
                        "delayComposition": {
                            "FL": 26,
                            "TO": 4,
                            "TR": 12,
                        },
                        "efficiency": 95.8,
                        "evaluation": "42ms / 1000ms(95.80%)",
                        "id": "160489627533733",
                        "index": 51,
                        "localDelay": 144,
                        "localEfficiency": 65.6,
                        "offloadFlag": "LC",
                        "offloadTo": 2,
                        "pairs": "2 &rarr; 2 (LC)",
                        "result": "Elon Musk",
                        "snapshot": "https://cdn.jsdelivr.net/gh/AmaneHayashi/PictureBed/elonmusk.jpg",
                        "timestamps": ["20-11-09 12:31:15", "20-11-09 12:31:15", "20-11-09 12:31:15"],
                        "typeAbbr": "FR"
                    },
                    "taskComposition": {
                        "yValue": {
                            "TO": 34,
                            "FL": 116,
                            "TR": 87
                        }
                    },
                    "taskDelay": {
                        "yValue": {
                            "GR-TO": [17, 14, 15, 16, 17, 18, 17, 14, 15, 16, 17, 18, 17, 14, 15],
                            "GR-LC": [46, 42, 51, 68, 43, 37, 44, 69, 72, 34, 48, 32, 33, 34, 35],
                            "FR-LC": [188, 187, 193, 176, 156, 178, 165, 187, 167, 192, 183, 171, 180, 165, 145],
                            "FR-TO": [128, 126, 132, 130, 145, 135, 125, 131, 138, 140, 137, 123, 130, 127, 142]
                        }
                    },
                    "taskDelayDist": {
                        "xAxis": [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],
                        "yValue": {
                            "GR": [50, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                            "FR": [49, 0, 0, 1, 0, 0, 0, 0, 0, 1]
                        }
                    },
                    "taskEff": {
                        "yValue": {
                            "LC": [65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6, 65.6],
                            "TO": [97.2, 97.399994, 96.8, 97.0, 95.5, 96.5, 97.5, 96.9, 96.200005, 96.0, 96.3, 97.7, 97.0, 97.299995, 95.8]
                        }
                    },
                    "taskEffDist": {
                        "xAxis": [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                        "yValue": {
                            "LC": [51, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                            "TO": [1, 0, 0, 0, 0, 0, 1, 0, 0, 49]
                        }
                    },
                    "taskFlow": [51 + (countR++), "FR", "2 &rarr; 2 (LC)", "42ms / 1000ms(95.80%)", "Elon Musk"],
                    "xAxisDynamic": [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]
                }
            };
            str = JSON.stringify(str);
            ws.send(str);
        });
    }
}

count = 0;

demoNet = () => {
    if(ws.readyState === 1) {
        if (count % 28 < 4) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }/*, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },*/]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else if (count % 28 < 8) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }/*, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },*/]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else if (count % 28 < 12) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }/*, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },*/]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else if (count % 28 < 16) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }/*, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },*/]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else if (count % 28 < 20) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else if (count % 28 < 24) {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 7,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        },]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        } else {
            str = {
                "key": "statistics/net",
                "value": {
                    "comNet": {
                        "id": "1604896967519",
                        "links": [{
                            "esDelay": 6.0,
                            "nodeDes": 2,
                            "nodeSrc": 1,
                            "rate": 8.76
                        }, {
                            "esDelay": 7.0,
                            "nodeDes": 3,
                            "nodeSrc": 1,
                            "rate": 13.54
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 1,
                            "nodeSrc": 2,
                            "rate": 2.68
                        }, {
                            "esDelay": 4.0,
                            "nodeDes": 3,
                            "nodeSrc": 2,
                            "rate": 6.19
                        }, {
                            "esDelay": 6.0,
                            "nodeDes": 1,
                            "nodeSrc": 3,
                            "rate": 3.88
                        }, {
                            "esDelay": 3.0,
                            "nodeDes": 2,
                            "nodeSrc": 3,
                            "rate": 5.84
                        }],
                        "network": {
                            "computing": 16.0,
                            "esDelay": 5.0,
                            "rate": 6.0,
                            "storage": 58.0
                        },
                        "nodes": [{
                            "id": 1,
                            "restComputing": [4.0, 2.096, 31.90],
                            "restStorage": [4096.0, 75.67]
                        }, {
                            "id": 2,
                            "restComputing": [6.0, 2.52, 13.78],
                            "restStorage": [4096.0, 52.28]
                        }, {
                            "id": 3,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 4,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 5,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 6,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 7,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }, {
                            "id": 8,
                            "restComputing": [4.0, 2.496, 3.95],
                            "restStorage": [4096.0, 48.35]
                        }]
                    },
                    "netComputing": {
                        "yValue": {
                            "value": [15.0, 16.0, 16.0, 16.0, 16.0, 16.0]
                        }
                    },
                    "netStorage": {
                        "yValue": {
                            "value": [58.0, 58.0, 58.0, 58.0, 58.0, 58.0]
                        }
                    },
                    "xAxisDynamic": ["12:42:07", "12:42:15", "12:42:23", "12:42:31", "12:42:39", "12:42:47"]
                }
            };
        }
        count ++;
        str = JSON.stringify(str);
        ws.send(str);
    }
}